package com.ruoyi.basedocument.service.impl;

import java.util.List;

import com.ruoyi.basedocument.domain.BomCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.basedocument.mapper.BomCostcenterMapper;
import com.ruoyi.basedocument.domain.BomCostcenter;
import com.ruoyi.basedocument.service.IBomCostcenterService;

/**
 * 成本中心Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-10-11
 */
@Service
public class BomCostcenterServiceImpl implements IBomCostcenterService 
{
    @Autowired
    private BomCostcenterMapper bomCostcenterMapper;

    /**
     * 查询成本中心
     * 
     * @param id 成本中心主键
     * @return 成本中心
     */
    @Override
    public BomCostcenter selectBomCostcenterById(String id)
    {
        return bomCostcenterMapper.selectBomCostcenterById(id);
    }

    /**
     * 查询成本中心列表
     * 
     * @param bomCostcenter 成本中心
     * @return 成本中心
     */
    @Override
    public List<BomCostcenter> selectBomCostcenterList(BomCostcenter bomCostcenter)
    {
        return bomCostcenterMapper.selectBomCostcenterList(bomCostcenter);
    }

    /**
     * 新增成本中心
     * 
     * @param bomCostcenter 成本中心
     * @return 结果
     */
    @Override
    public int insertBomCostcenter(BomCostcenter bomCostcenter)
    {
        BomCostcenter obj = new BomCostcenter();
        obj.setNumber(bomCostcenter.getNumber());
        List<BomCostcenter> objs = bomCostcenterMapper.selectBomCostcenterList2(obj);
        if(objs!=null&&objs.size()!=0){
            throw new RuntimeException("编码已存在:"+bomCostcenter.getNumber());
        }
        return bomCostcenterMapper.insertBomCostcenter(bomCostcenter);
    }

    /**
     * 修改成本中心
     * 
     * @param bomCostcenter 成本中心
     * @return 结果
     */
    @Override
    public int updateBomCostcenter(BomCostcenter bomCostcenter)
    {
        return bomCostcenterMapper.updateBomCostcenter(bomCostcenter);
    }

    /**
     * 批量删除成本中心
     * 
     * @param ids 需要删除的成本中心主键
     * @return 结果
     */
    @Override
    public int deleteBomCostcenterByIds(String[] ids)
    {
        return bomCostcenterMapper.deleteBomCostcenterByIds(ids);
    }

    /**
     * 删除成本中心信息
     * 
     * @param id 成本中心主键
     * @return 结果
     */
    @Override
    public int deleteBomCostcenterById(String id)
    {
        return bomCostcenterMapper.deleteBomCostcenterById(id);
    }
}
